//
//  AiRoleBean.swift
//  imprint
//
//  Created by 小柠檬🍋 on 2025/1/8.
//

import Foundation
import LeanCloud
import GRDB

public class AiRoleBean : ICloudTable,IDbTable, Identifiable {
    
    public static let databaseTableName = "AiRole"

    func getCloudTable() -> String {
        return "AiRole"
    }
    
    func doCustomExcluded() -> [String? : Any?] {
        return doExcluded(subject: self, excluded: ["select","createTime","updateTime","modifySign"])
    }
    
    
    //db排除字段
    func doCustomDBExcluded()  -> [String? : Any?] {
        return doExcluded(subject: self, excluded: ["select"])
    }
    
    init() {
        userId = userManager.getUserId()
    }
    
    var objectId: String?
    var userId: String? = nil
    var name:String? = nil
    var name2:String? = nil //称呼
    var describe:String? = nil
    var describe2:String? = nil //我的人设
    var describeChat:String? = nil //聊天回复规则
    var hideDescribe: String? = nil//隐藏人设
    var avatar:String?=nil
    var sexName: String? = nil//性别
    var voice: AiVoiceBean? = nil//音色
    var isSystem: Bool? = false//是否是系统
    
    var createTime: Int64 = 0//创建时间
    var updateTime: Int64 = 0//更新时间时间
    var modifySign: Bool = false//修改标识
    var status: Int = IStatusType.NORMAL.rawValue
    var sort: Int = 0
    var chatBg: String? = nil //聊天背景
    var diaryBg: String? = nil //日记背景
    var bubbleId: String? = nil //气泡
    var bubbleCommentId: String? = nil //评论气泡
    var hideChatRecord: Bool? = false //隐藏聊天记录


    //以下字段排除
    var select:Bool = false
    
    
    //json解析白名单
    private enum CodingKeys: String, CodingKey {
        case objectId
        case name
        case name2
        case describe
        case describe2
        case hideDescribe
        case avatar
        case sexName
        case voice
        case isSystem
        case sort
        case chatBg
        case diaryBg
        case bubbleId
        case bubbleCommentId
        case hideChatRecord
        case describeChat
        // 这里不包含 select，所以 select 会被忽略
    }
}


extension AiRoleBean {
    // db数据库指定字段
    public func encode(to container: inout PersistenceContainer) {
        doDBExcluded(to: &container)
    }
}
